package com.rsk.api;



import javax.ws.rs.QueryParam;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.config.annotation.Reference;
import com.rsk.api.common.ReturnUtils;
import com.rsk.service.SysLevelService;
import com.rsk.utils.result.Result;

@RestController
@RequestMapping(value="/sys/level")
public class SystemLevelApi {
	
	@Reference(interfaceClass = SysLevelService.class, protocol = "dubbo")
	private SysLevelService sysLevelService;
	
	
	//@RequiresPermissions("sys_users:save")
	@PostMapping(value="/saveSysLevel" )
	public Result<String> saveSysLevel(@QueryParam("levelName") String levelName,
		   							   @QueryParam("levelCode") String levelCode,
		   							   @QueryParam("deptId") Long deptId,
		   							   @RequestHeader("Authorization") String Authorization){
		//数据校验
		//String operatorUser = JwtUtil.getClaim(Authorization, "account");
		Long operatorUser = 123L;
		int i = sysLevelService.saveSysLevel(levelName, levelCode, deptId, operatorUser);
		return ReturnUtils.returnDataByOne(i);
	}
	
	//@RequiresPermissions("sys_users:update")
	@PostMapping(value="/updateSysLevel" )
	public Result<String> updateSysLevel(@QueryParam("id") Long id,
									     @QueryParam("levelName") String levelName,
									     @RequestHeader("Authorization") String Authorization){
		//数据校验
		//String operatorUser = JwtUtil.getClaim(Authorization, "account");
		Long operatorUser = 123L;
		int i = sysLevelService.updateSysLevel(id, levelName, operatorUser);
		return ReturnUtils.returnDataByOne(i);
	}
	
	
	
	//@RequiresPermissions("sys_users:del")
	@PostMapping(value="/delSysLevel" )
	public Result<String> delSysLevel(@QueryParam("id") Long id,
									 @RequestHeader("Authorization") String Authorization){
		//String operatorUser = JwtUtil.getClaim(Authorization, "account");
		Long operatorUser = 123L;
		int i = sysLevelService.delSysLevel(id, operatorUser);
		return ReturnUtils.returnDataByOne(i);
	}
	
}
